package name.matthewgreet.example6.view; import name.matthewgreet.example6.action.ViewGameListAction.GameCategory; import name.matthewgreet.example6.dto.GameDTO; import name.matthewgreet.example6.util.Example6FormatLibrary; public class GameDisplay { private String id; private String name; private String description; private String yearPublished; private String gameWeight; private String gameWeightDesc; private String userRating; private String userRatingDesc; private String owners; private String family; private String players; private String minAge; private String playTime; private String rankAll; private String rankStrategy; private String rankAbstract; private String rankFamily; private String rankThematic; private String rankCustomizable; private String rankWar; private String rankParty; private String rankChildren; private String imageURL; private String preferredRank; private String categoriesText; private String artistsTextNonBreaking; private String designersText; private String designersTextNonBreaking; private String mechanicsTextNonBreaking; private String publishersTextNonBreaking; public GameDisplay(GameDTO game, GameCategory preferredCategory) { id = Integer.toString(game.getId()); name = game.getName(); description = game.getDescription(); yearPublished = Integer.toString(game.getYearPublished()); gameWeight = Example6FormatLibrary.formatGameWeight(game.getGameWeight()); gameWeightDesc = Example6FormatLibrary.formatGameWeightDesc(game.getGameWeight()); userRating = Example6FormatLibrary.formatUserRating(game.getAvgRating()); userRatingDesc = Example6FormatLibrary.formatUserRatingDesc(game.getAvgRating()); owners = Example6FormatLibrary.formatNumber(game.getOwned()); family = game.getFamily(); players = Integer.toString(game.getMinPlayers()) + "-" + Integer.toString(game.getMaxPlayers()); minAge = Integer.toString(game.getRecommendedAge()); playTime = Integer.toString(game.getPlayTime()) + " mins"; rankAll = (game.getRankAll() != null)?game.getRankAll().toString():""; rankStrategy = (game.getRankStrategy() != null)?game.getRankStrategy().toString():""; rankAbstract = (game.getRankAbstract() != null)?game.getRankAbstract().toString():""; rankFamily = (game.getRankFamily() != null)?game.getRankFamily().toString():""; rankThematic = (game.getRankThematic() != null)?game.getRankThematic().toString():""; rankCustomizable = (game.getRankCustomizable() != null)?game.getRankCustomizable().toString():""; rankWar = (game.getRankWar() != null)?game.getRankWar().toString():""; rankParty = (game.getRankParty() != null)?game.getRankParty().toString():""; rankChildren = (game.getRankChildren() != null)?game.getRankChildren().toString():""; imageURL = game.getImageURL(); preferredRank = ""; if (preferredCategory != null) { switch (preferredCategory) { case ABSTRACT: preferredRank = rankAbstract; break; case ALL: preferredRank = rankAll; break; case CHILDREN: preferredRank = rankChildren; break; case CUSTOMIZABLE: preferredRank = rankCustomizable; break; case FAMILY: preferredRank = rankFamily; break; case PARTY: preferredRank = rankParty; break; case STRATEGY: preferredRank = rankStrategy; break; case THEMATIC: preferredRank = rankThematic; break; case WAR: preferredRank = rankWar; break; } } categoriesText = Example6FormatLibrary.formatCategoriesText(game.getRankAbstract() != null, game.getRankChildren() != null, game.getRankCustomizable() != null, game.getRankFamily() != null, game.getRankParty() != null, game.getRankStrategy() != null, game.getRankThematic() != null, game.getRankWar() != null); artistsTextNonBreaking = Example6FormatLibrary.formatArtistsText(game.getArtists(), game.getOtherArtists(), true); designersText = Example6FormatLibrary.formatDesignersText(game.getDesigners(), game.getOtherDesigners(), false); designersTextNonBreaking = Example6FormatLibrary.formatDesignersText(game.getDesigners(), game.getOtherDesigners(), true); mechanicsTextNonBreaking = Example6FormatLibrary.formatMechanicsText(game.getMechanics(), true); publishersTextNonBreaking = Example6FormatLibrary.formatPublishersText(game.getPublishers(), game.getOtherPublishers(), true); } public String getId() { return id; } public String getName() { return name; } public String getDescription() { return description; } public String getYearPublished() { return yearPublished; } public String getGameWeight() { return gameWeight; } public String getGameWeightDesc() { return gameWeightDesc; } public String getUserRating() { return userRating; } public String getUserRatingDesc() { return userRatingDesc; } public String getOwners() { return owners; } public String getFamily() { return family; } public String getPlayers() { return players; } public String getMinAge() { return minAge; } public String getPlayTime() { return playTime; } public String getRankAll() { return rankAll; } public String getRankStrategy() { return rankStrategy; } public String getRankAbstract() { return rankAbstract; } public String getRankFamily() { return rankFamily; } public String getRankThematic() { return rankThematic; } public String getRankCustomizable() { return rankCustomizable; } public String getRankWar() { return rankWar; } public String getRankParty() { return rankParty; } public String getRankChildren() { return rankChildren; } public String getImageURL() { return imageURL; } public String getPreferredRank() { return preferredRank; } public String getArtistsTextNonBreaking() { return artistsTextNonBreaking; } public String getCategoriesText() { return categoriesText; } public String getDesignersText() { return designersText; } public String getDesignersTextNonBreaking() { return designersTextNonBreaking; } public String getMechanicsTextNonBreaking() { return mechanicsTextNonBreaking; } public String getPublishersTextNonBreaking() { return publishersTextNonBreaking; } @Override public String toString() { return "GameDisplay [id=" + id + ", name=" + name + ", description=" + description + ", yearPublished=" + yearPublished + ", gameWeight=" + gameWeight + ", gameWeightDesc=" + gameWeightDesc + ", userRating=" + userRating + ", userRatingDesc=" + userRatingDesc + ", owners=" + owners + ", family=" + family + ", players=" + players + ", minAge=" + minAge + ", playTime=" + playTime + ", rankAll=" + rankAll + ", rankStrategy=" + rankStrategy + ", rankAbstract=" + rankAbstract + ", rankFamily=" + rankFamily + ", rankThematic=" + rankThematic + ", rankCustomizable=" + rankCustomizable + ", rankWar=" + rankWar + ", rankParty=" + rankParty + ", rankChildren=" + rankChildren + ", imageURL=" + imageURL + ", preferredRank=" + preferredRank + ", categoriesText=" + categoriesText + ", artistsTextNonBreaking=" + artistsTextNonBreaking + ", designersText=" + designersText + ", designersTextNonBreaking=" + designersTextNonBreaking + ", mechanicsTextNonBreaking=" + mechanicsTextNonBreaking + ", publishersTextNonBreaking=" + publishersTextNonBreaking + "]"; } }